import flask
import request
import jsonify
import pymysql.cursors

def login(host,user,passwd,db,table):
    connect = pymysql.Connect(host,user,passwd,db)
# 获取数据库游标
    cursor = connect.cursor()
# 使用预处理语句创建表
    sql = """CREATE TABLE %s (
            `id` bigint(20) NOT NULL AUTO_INCREMENT,
            `url` varchar(255) DEFAULT NULL,
            `name` varchar(255) DEFAULT NULL,
            `urlavi` varchar(1000) DEFAULT NULL,
            `urlimg` varchar(1000) DEFAULT NULL,
            `time` datetime DEFAULT NULL,
            PRIMARY KEY (`id`)
            )""" %(table)
    try:
        cursor.execute(sql)
        connect.close()
        return "表创建成功"
    except:
        connect.close()
        return "表创建失败"
